class Solution {
public:
    int minRefuelStops(int target, int startFuel, vector<vector<int>>stations)
    {
        stations.push_back(vector<int>(1, target));
        priority_queue<int> que;
        int pos = 0, ans = -1, num = 0;
        que.push(startFuel);
        while (!que.empty())
        {
            num += que.top();
            que.pop();
            ans += 1;
            while (stations[pos][0] <= num)
            {
                if (pos == stations.size() - 1) return ans;
                que.push(stations[pos][1]);
                pos += 1;
            }
        }
        return -1;
    }
};